<?php
/**
 * Created by PhpStorm.
 * User: 钊鑫
 * Date: 2019/2/19
 * Time: 9:13
 */
namespace app\api\controller;

class Excel
{
    public function export()
    {
        $strTable = '<table width="500" border="1">';
        $strTable .= '<tr>';
        $strTable .= '<td style="text-align:center;font-size:12px;width:120px;">会员ID</td>';
        $strTable .= '<td style="text-align:center;font-size:12px;" width="100">会员昵称</td>';
        $strTable .= '<td style="text-align:center;font-size:12px;" width="*">会员等级</td>';
        $strTable .= '<td style="text-align:center;font-size:12px;" width="*">手机号</td>';
        $strTable .= '<td style="text-align:center;font-size:12px;" width="*">邮箱</td>';
        $strTable .= '<td style="text-align:center;font-size:12px;" width="*">注册时间</td>';
        $strTable .= '<td style="text-align:center;font-size:12px;" width="*">最后登陆</td>';
        $strTable .= '<td style="text-align:center;font-size:12px;" width="*">余额</td>';
        $strTable .= '<td style="text-align:center;font-size:12px;" width="*">积分</td>';
        $strTable .= '<td style="text-align:center;font-size:12px;" width="*">累计消费</td>';
        $strTable .= '</tr>';

        $strTable .= '<tr>';
        $strTable .= '<td style="text-align:center;font-size:12px;">111</td>';
        $strTable .= '<td style="text-align:left;font-size:12px;">222</td>';
        $strTable .= '<td style="text-align:left;font-size:12px;">333</td>';
        $strTable .= '<td style="text-align:left;font-size:12px;">444</td>';
        $strTable .= '<td style="text-align:left;font-size:12px;">555</td>';
        $strTable .= '<td style="text-align:left;font-size:12px;">666</td>';
        $strTable .= '<td style="text-align:left;font-size:12px;">777</td>';
        $strTable .= '<td style="text-align:left;font-size:12px;">888</td>';
        $strTable .= '<td style="text-align:left;font-size:12px;">999 </td>';
        $strTable .= '<td style="text-align:left;font-size:12px;">000 </td>';
        $strTable .= '</tr>';
        $strTable .= '</table>';

        header("Content-type: application/vnd.ms-excel");
        header("Content-Type: application/force-download");
        header("Content-Disposition: attachment; filename=excel_".date('Y-m-d').".xls");
        header('Expires:0');
        header('Pragma:public');
        echo '<html><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'.$strTable.'</html>';
    }

}